package com.colin.app.activity.other.jni;

import android.widget.TextView;

import com.colin.app.R;
import com.colin.app.activity.other.OtherContract;
import com.colin.app.activity.other.OtherPresenterImpl;
import com.colin.app.app.AppActivity;
import com.colin.app.bean.DemoBean;

/**
 * 总结一下流程：
 * <p>
 * 编写静态方法（用java声明）-->编译生成class文件--->编译生成h文件---->编写C文件（用C/C++实现）
 * ---->配置NDK---->配置so库---->在Activity调用（Java调用C/C++）。
 */
public class JniActivity extends AppActivity implements OtherContract.OtherView {
    private OtherContract.OtherPresenter mOtherPresenter = null;
    private TextView text_jni_test ;

    @Override
    protected void onDestroy() {
        if (null != mOtherPresenter) {
            mOtherPresenter.destroy();
            mOtherPresenter = null;
        }
        super.onDestroy();
    }

    @Override
    public void initPresenter() {
        DemoBean demoBean = getIntent().getExtras().getParcelable("clazz");
        mOtherPresenter = new OtherPresenterImpl(this, this, demoBean);
    }


    @Override
    public int initViewLayoutID() {
        return R.layout.activity_jni;
    }

    @Override
    public void initView() {
        this.text_jni_test = (TextView) this.findViewById(R.id.text_jni_test);
    }

    @Override
    public void initData() {
        mOtherPresenter.setData();
        this.text_jni_test.setText(JniNdkForC.sayHelloByC());
    }

}
